<?php
	$sql = new db();
	$req = "SELECT co.*, en.Nom AS en_nom, cl.Raison_Social, us.Nom AS us_nom FROM entrepot AS en, usine AS us, commande AS co, client AS cl WHERE co.Id_Commande = ".$_GET['idcom']." AND cl.GLN_Client = co.GLN_Client AND co.GLN_DO = us.GLN_DO AND co.GLN_Entrepot = en.GLN_Entrepot";
	$sql->query($req);
	$res_com = $sql->fetch_array();
	switch($res_com['Etat']) 
	  {
	   case 'e':
	    $etat_val =  "En cours ...";
		break;
	   case 'v':
	    $etat_val =  "En cours ...";
		break;
	   case 'r': 
	    $etat_val = "Refus&eacute;e.";
		break;
	   case 'l':
	    $etat_val =  "Livrée !";
	    break;
	   case 'c':
	    $etat_val = "En cours ...";
	    break;
	   case 'p':
	    $etat_val =  "A traiter ...";
		break;
		case 's':
		$etat_val = "A livrer...";
		break;
		case 'd':
		$etat_val =  "En livraison...";
		break;
	  }
	$req = "SELECT pr.Date_diffusion_ordre_prepa, pr. Description, pr.Date_fin FROM preparation AS pr WHERE pr.Id_Commande = ".$_GET['idcom'];
	$sql->query($req);
	$res_pre = $sql->fetch_array();
	if (empty($res_pre))
		{
			$res_pre['Date_diffusion_ordre_prepa'] = "N/a";		
			$res_pre['Date_fin'] = "N/a";
		}
	$req = "SELECT prix FROM proposition_affretement WHERE Id_Commande =".$_GET['idcom'];
	$sql->query($req);
	$res_prix = $sql->fetch_array();
	$res_prix['prix'] .= " euros";
	$req = "SELECT Prix_offre, Etat FROM offre_transport WHERE Id_Commande =".$_GET['idcom']." AND GLN_Transporteur = ".$_SESSION['login'];
	$sql->query($req);
	if ($sql->num_rows() != 0)
		{
			$tmp = $sql->fetch_array();
			$offre_liv = $tmp['Etat'];
			  switch($offre_liv) 
			  {
			   case 'P':
			    $offre_liv = "Propos&eacute;e";
				break;
			   case 'A':
			    $offre_liv = "Accept&eacute;e";
				break;
			   case 'R': 
			    $offre_liv = "Refus&eacute;e.";
				break;
			  }
			  $cout_liv = $tmp['Prix_offre']." euros";
		}
	else
	{
		$offre_liv = "<a href=\"javascript:;\" onClick=\"MkOffre('".$_GET['idcom']."');\">Proposer</a>";
		$cout_liv = "n/a";
	}
 ?>